#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <sstream> 
#include "gui_chung_dll.h"
#include "opengl.h"
//link with libgui_chung_dll.dll.a
//link with -lopengl32 -lglu32

using namespace std;

const string str(double var){ostringstream str;str << var;return str.str();};
void notice(const string text){MessageBox(NULL,text.c_str(),"notice",MB_OK);};

uint quit,i,j,k;
const char* liste[100];
void subquit(){quit=1;};
void subcombo(){
     getcomboindex("win.combo",&i);notice(str(i)+guicurrentcontrolname());};
void submenu(){notice(guicurrentcontrolname());};
void subbutton(){notice("button clicked !");}

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
liste[0]="liste0";
liste[1]="liste1";
liste[2]="liste2";
combobox("win.combo",subcombo,20,20,100,100);
graphicbox("win.graph",20,50,300,300,"opengl");
graphicbox("win.graph2",340,50,300,300,"gfx");
button("win.button","click here",subbutton,200,15,70,25);
openwindow("win","mywindow",100,20,700,420);

trapclose("win",subquit);
addcombo("win.combo","item1");
addcombo("win.combo","item2");
reloadcombo("win.combo",liste);
selectcombotext("win.combo","liste2",liste);
addmenu("win.menu","mymenu");
addmenuitem("win.menu.item1","item1",submenu);
addmenuitem("win.menu.item2","item2",submenu);

guistartOpenGL("win.graph");
mytexture=guiloadtexture("bmp/fleur.jpg");

guidrawcolor(100,255,255,255);
guidrawbox("win.graph2",40,40,200,200,1);
guirefreshwindow("win");

while (quit==0 and guitestkey(VK_ESCAPE)==0){
      guiscan();
      guisleep(50);
      drawopengl();
      guirefreshopenGL();
      }
      
guicloseOpenGL();

guiclose();
guiquit();
notice("end");
return 0;
}


